package com.yy.wga.admin.service.controller;

import com.yy.wga.module.admin.request.*;
import com.yy.wga.mp.common.aop.NotLogin;
import com.yy.wga.mp.module.admin.request.AdminUserPageRequest;
import com.yy.wga.mp.module.admin.request.AdminUserSaveRequest;
import com.yy.wga.mp.module.admin.request.AdminUserUpdateStatusRequest;
import com.yy.wga.mp.module.admin.response.AdminUserPageResponse;
import com.yy.wga.mp.module.admin.service.AdminUserService;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * 运营后台/账号管理
 *
 * @author guochao
 * @since 2022-11-01 19:08:37
 */
@RestController
@RequestMapping("/admin/user")
public class AdminUserController {
    /**
     * 服务对象
     */
    @Resource
    private AdminUserService adminUserService;

    @NotLogin
    @PostMapping(value = "/page")
    public Result<PageBean<AdminUserPageResponse>> page(@RequestBody @Valid AdminUserPageRequest request) {
        PageBean<AdminUserPageResponse> pageBean = adminUserService.pageData(request);
        return Result.success(pageBean);
    }

    @PostMapping(value = "/updateStatus")
    public Result<Boolean> updateStatus(@RequestBody @Valid AdminUserUpdateStatusRequest request) {
        adminUserService.updateStatus(request);
        return Result.success(Boolean.TRUE);
    }

    @PostMapping(value = "/save")
    public Result<Boolean> save(@RequestBody @Valid AdminUserSaveRequest request) {
        adminUserService.saveUser(request);
        return Result.success(Boolean.TRUE);
    }

    @GetMapping(value = "/del")
    public Result<Boolean> del(@RequestParam("id") Long id) {
        adminUserService.delUser(id);
        return Result.success(Boolean.TRUE);
    }
}
